/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cn.ekuma.data.dao;

import cn.ekuma.data.dao.bean.IKeyed;
import cn.ekuma.data.dao.bean.I_BaseBean;
import cn.ekuma.data.dao.bean.I_ViewBean;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.query.QBFParameter;
import com.openbravo.data.loader.query.QBFParameters;

import java.util.Date;
import java.util.List;

/**
 *
 * @author Administrator
 */
public interface I_DataLogic {
	
	public I_Session getSession();
	
    public int insert(I_BaseBean obj) throws BasicException;

    public int update(I_BaseBean obj) throws BasicException;

    public int delete(I_BaseBean obj) throws BasicException;
    
    public int deleteByIKeyed(Class c,IKeyed k) throws BasicException;
    
    public int deleteByQBFParameters(Class c,QBFParameters filter) throws BasicException;

    public int insertObjs(List objs) throws BasicException;
    
    public IKeyed insertAutoGenerator(I_BaseBean obj) throws BasicException;

    public int updateObjs(List objs) throws BasicException;

    public int deleteObjs(List objs) throws BasicException;
    
    public int insertOrUpdate(final List objs) throws BasicException;
    
    public int insertOrUpdate(I_BaseBean objs) throws BasicException;

    public I_ViewBean find(Class c,IKeyed id) throws BasicException;

    public I_ViewBean findByStringId(Class c, String id) throws BasicException;

    public I_ViewBean findByIntId(Class c, int id) throws BasicException;
    
    public List list(Class c) throws BasicException;

    public List listByFilter(Class c,Object filter) throws BasicException;
    
    public List listByFilterWithClassName(String c,Object filter) throws BasicException;
    
    public List query(Class c,QBFParameters filter) throws BasicException;
    
    public List queryByQBFParameter(Class c,QBFParameter filter) throws BasicException;

    public List queryByQBFParameters(String c,QBFParameters filter) throws BasicException;
    
    public List listByParent(Class c,I_ParentNode parent) throws BasicException;

    public List list(Class c,Class parent,String id) throws BasicException;
    
    public int updateByFieldWithIKeyed(IKeyed obj,String field,final Object newValue) throws BasicException;

    public int updateByField(Class c,IKeyed obj,String field,final Object newValue) throws BasicException;
    
    public ViewDAO getDao(Class c);
    
    int clear(Class c)throws BasicException;

	public List listWithClassName(String name)throws BasicException;
	
	public List listWithParentClassAndKey(String c,String parent,String id) throws BasicException;
	
	public List listWithDateTime(Class c,Date start,Date end) throws BasicException;
	
	public List listWithDateTimeByClassName(String c,Date start,Date end) throws BasicException;
	
	public boolean isExistByField(Class c,String field,Object fiald)throws BasicException;
	
	public boolean isExistByFields(Class c, String[] fields, Object[] values)throws BasicException;
}
